<?php
/**
 * Created by PhpStorm.
 * User: 王世鹏
 * Date: 2018/3/8
 * Time: 16:14
 */

namespace app\index\controller;

use app\index\model\Info as InfoModel;
use think\Request;


class Info
{
    public function add()
    {
        $model = new InfoModel();
        if($result = $model->save(input("post."))){
            return "ok";
        }
        else{
            return $model->getError();
        }

    }


    public function update(Request $request)
    {
        $model = new InfoModel();
        if($result = $model->save($request->except("id"),["id"=>input("post.id")])){
            return "ok";
        }
        else{
            return $model->getError();
        }

    }


    public function del()
    {
        $data = InfoModel::get(input("post.id"));
        if($data){
            $data->delete();
            return "ok";
        }
        else{
            return $data->getError();
        }

    }


}